#include "Trajectory.h"
#include "TrajSet.h"
//#include "clusters.h"
#include "dbscan.h"








int main()
{
  
	using namespace Metrics;

	
	//test for open a directory
	vector<TrajSet> vTrajSet;

	char repertory[20];
	char repertory1[20];
	
	/*cout << "Enter the number of the user you want the trajectories from" << endl;
	cout << "When you don't want to add user anymore just enter 'a'" << endl;
	cin >> repertory;*/
	int numFolder = 0;
	while(numFolder < 167){
	//while(repertory[0] != 'a'){

		itoa(numFolder,repertory,10);

		 // C string you want to modify
		
		int len = 3-strlen(repertory); // get the missing part size
		memmove(repertory+len,repertory,strlen(repertory)); // move the string characters to the end
		for ( int i = 0; i < len; i++ ) // fill the beginning characters with '0'
			repertory[i] = '0';


		//cout << repertory << endl;

		
		TrajSet t = TrajSet(repertory); // to process all the files, just replace repertory with "*" and remove the while
	
	
		vTrajSet.push_back(t);

		numFolder++;
		
	}

	Clustering::Points ps;

	
	// random init points dataset (dims, points)
	Clustering::getSetOfDatas(ps, vTrajSet);   
	
	         

	// build similarity  matrix
	Distance<MeterDistance<Clustering::Point>> d;


	// init: sim threshold, minPts
	Clustering::DBSCAN* clusters = new Clustering::DBSCAN(ps, 1, 5); 


	cout << "here5" << endl;
	
	//clusters.computeSimilarity(d, 20, 3600);     
	
	// run clustering
	// second value thresholdGeographic in meters, third value thresholdTime in second
	clusters->run_cluster(d, 20.0, 900.0); // 10 meters, 15mn
	cout << "here6" << endl;
	
	//create coordinates
	clusters->createClusterCordinates();
	cout << "here7" << endl;
	

	ofstream out("cluster_result.txt");

	out << *clusters << endl; 
	
	out.close();
	

	//readClustersFile("cluster_result.txt");

	cout << "End" << endl;
	system("pause");
}